<template>
    <view class="" v-if="actionShowClone" :class="'wx-actionsheet_mask wx-actionsheet_' + mask" @tap="actionHide">
        <view :class="'wx-actionsheet_main wx-actionsheet_animated wx-actionsheet_' + animation">
            <view class="tkcom">
                <text class="title">签到名称</text>
                <view class="paragraph_1">
                    <text>链接：</text>
                    <text></text>
                </view>
                <view class="paragraph_1">
                    <text>房间号：</text>
                    <text>{{ meetingCode }}</text>
                </view>
                <view class="btncom">
                    <button style="display: none" class="button1" type="primary">复制链接</button>
                    <button style="display: none" class="button1" type="primary">下载海报</button>
                    <button @tap="downloadMeetingCode" class="button1" type="primary">下载二维码</button>
                </view>
            </view>
            <view class="group_3" style="display: none">
                <text lines="1" class="text_5">分享到</text>
                <view class="image-text_1">
                    <view class="group_4">
                        <button open-type="share"></button>
                    </view>
                    <text lines="1" class="text-group_2">微信</text>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
var animation = uni.createAnimation({
    duration: 200,
    timingFunction: 'linear',
    delay: 0
});
import api from '../../../utils/api';
const app = getApp();
export default {
    data() {
        return {
            mask: '',
            animation: 'showAction',
            actionShowClone: false,
            closeTextClone: ''
        };
    },
    /**
     * 组件的属性列表
     */
    props: {
        meetingCode: {
            type: String
        },
        // 组件的初始显隐
        actionShow: {
            type: Boolean,
            default: false
        },
        // 取消按钮的文字
        closeText: {
            type: String,
            default: '取消'
        }
    },
    /**
     * 组件的方法列表
     */
    methods: {
        // 取消按钮响应事件
        actionHide: function () {
            var that = this;
            this.setData({
                animation: 'hideAction',
                mask: 'transparent'
            });
            setTimeout(function () {
                that.setData({
                    actionShowClone: false
                });
            }, 600);
            var myEventDetail = {};
            var myEventOption = {};
            this.$emit(
                'actionHide',
                {
                    detail: myEventDetail
                },
                myEventOption
            );
        },

        //下载二维码
        downloadMeetingCode() {
            console.log('downloadMeetingCode');
            var that = this;
            api.post('/rest/api/downloadMeetingCode', {
                code: that.meetingCode
            }).then((res) => {
                console.log(res);
                uni.downloadFile({
                    url: app.globalData.serverUrl + res.data
                });
            });
        }
    },
    watch: {
        actionShow: {
            handler: function (newVal, oldVal) {
                this.actionShowClone = ...this.actionShow;
                this.animation = animation;
                animation.opacity(0).step(); // 显示

                if (newVal) {
                    this.setData({
                        actionShowClone: true,
                        mask: '',
                        animation: 'showAction'
                    });
                } else {
                    // var that = this
                    this.setData({
                        animation: 'hideAction',
                        mask: 'transparent',
                        actionShowClone: false
                    });
                }
            },

            immediate: true
        },

        closeText: {
            handler: function (newVal, oldVal) {
                this.closeTextClone = ...this.closeText;
                this.setData({
                    closeTextClone: newVal
                });
            },

            immediate: true
        }
    }
};
</script>
<style>
.wx-actionsheet_mask {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    overflow: hidden;
    bottom: 0;
}
.title {
    color: rgba(51, 51, 51, 1);
    font-size: 36rpx;
}

.wx-actionsheet_transparent {
    background: rgba(0, 0, 0, 0);
}

.wx-actionsheet_main {
    width: 100%;
    position: absolute;
    top: 100%;
    z-index: 1001;
    overflow: hidden;
    background-color: #fff;
    border-radius: 30rpx 30rpx 0 0;
}

.wx-actionsheet_main navigator,
.wx-actionsheet_close {
    text-align: center;
    background: #fff;
    border-radius: 0;
    line-height: 3;
    font-size: 32rpx;
    border-bottom: 1px solid #ececec;
    font-family: Arial, Helvetica, sans-serif;
}

.wx-actionsheet_close {
    border-bottom: none;
    border-top: 4px solid #ececec;
}

.wx-actionsheet_animated {
    animation-duration: 1s;
    animation-fill-mode: both;
}

@keyframes showAction {
    from {
        transform: translate3d(0, 0, 0);
    }

    to {
        transform: translate3d(0, -100%, 0);
    }
}

.wx-actionsheet_showAction {
    animation-name: showAction;
    animation-duration: 0.5s;
}

@keyframes hideAction {
    from {
        transform: translate3d(0, -100%, 0);
    }

    to {
        transform: translate3d(0, 0, 0);
    }
}

.wx-actionsheet_hideAction {
    animation-name: hideAction;
    animation-duration: 0.5s;
}
.tkcom {
    padding: 30rpx;
}
.paragraph_1 {
    color: rgba(102, 102, 102, 1);
    font-size: 28rpx;
    text-align: left;
    line-height: 48rpx;
    margin-top: 8rpx;
}
.button1 {
    background-color: rgba(26, 117, 255, 1) !important;
    border-radius: 8rpx !important;
    display: inline-block;
    flex-direction: column;
    padding: 14rpx 32rpx 14rpx 32rpx !important;
    font-size: 28rpx !important;
    width: auto !important;
    margin-right: 10rpx !important;
}
.btncom {
    margin-top: 20rpx;
}

.group_3 {
    background-color: rgba(255, 255, 255, 1);
    border-top: 10px solid #eee;
    margin-top: 0rpx;
    display: flex;
    flex-direction: column;
    padding: 30rpx 618rpx 44rpx 32rpx;
}
.text_5 {
    overflow-wrap: break-word;
    color: rgba(102, 102, 102, 1);
    font-size: 28rpx;
    font-family: PingFangSC-Semibold;
    text-align: left;
    white-space: nowrap;
    line-height: 40rpx;
    margin-right: 16rpx;
}
.image-text_1 {
    margin-top: 24rpx;
    display: flex;
    flex-direction: column;
}
.group_4 {
    border-radius: 20rpx;
    width: 100rpx;
    height: 100rpx;
    border: 1px solid rgba(216, 216, 216, 1);
    display: flex;
    flex-direction: column;
}
.text-group_2 {
    overflow-wrap: break-word;
    color: rgba(102, 102, 102, 1);
    font-size: 28rpx;
    font-family: PingFangSC-Regular;
    text-align: left;
    white-space: nowrap;
    line-height: 40rpx;
    align-self: center;
    margin-top: 12rpx;
}
</style>
